package com.huawei.esdk.tp.southcommu;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import com.huawei.esdk.platform.commu.itf.ICXFSOAPCustProvider;
import com.huawei.esdk.tp.interceptor.TPSmcInInterceptor;
import com.huawei.esdk.tp.interceptor.TPSmcLoggingInInterceptor;
import com.huawei.esdk.tp.interceptor.TPSmcOutInterceptor;

public class TPCXFSOAPCustProvider implements ICXFSOAPCustProvider
{

    @Override
    public Map<String, String> getSoapHeaders()
    {
        return null;
    }

    @Override
    public List<Object> getInInterceptors()
    {
        List<Object> list = new ArrayList<Object>();
        list.add(new TPSmcInInterceptor());
        list.add(new TPSmcLoggingInInterceptor());
        
        return list;
    }

    @Override
    public List<Object> getOutInterceptors()
    {
        List<Object> list =  new ArrayList<Object>();
        list.add(new TPSmcOutInterceptor());
        
        return list;
    }

    @Override
    public Map<String, String> getSerivceURIMapping()
    {
        return null;
    }
    
    @Override
    public String reBuildNewUrl(String url, String interfaceName)
    {
        String newUrl = url;
        //Prepare a new URL which contains the device version info
        String[] packages = interfaceName.split("\\.");
        if(packages.length >= 2)
        {
            newUrl = url + "|" + packages[packages.length - 2];
        }
        
        return newUrl;
    }
}
